package cn.edu.xmu.orderpayment.payment.model.vo;


import cn.edu.xmu.oomall.core.model.VoObject;
import cn.edu.xmu.orderpayment.payment.model.po.PaymentPatternPo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author  Guanlin Wang
 * @date  2021-11-12
 */

@Data
@NoArgsConstructor
public class PaymentPatternVo implements VoObject {
    private long id;//支付渠道id

    @ApiModelProperty(value = "支付渠道名称")
    private String name;

    @ApiModelProperty(value = "支付状态")//0：有效，1：无效
    private Byte state;

    @ApiModelProperty(value = "开始时间")
    private LocalDateTime beginTime;

    @ApiModelProperty(value = "结束时间")
    private LocalDateTime endTime;

    @ApiModelProperty(value = "全路径类名")
    private String className;

    public SimpleAdminUser creator;//创建者
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public LocalDateTime gmtCreate;//创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public LocalDateTime gmtModified;//修改时间
    public SimpleAdminUser modifier;//修改者


    public PaymentPatternPo createPo(){
        PaymentPatternPo paymentPatternPo = new PaymentPatternPo();
        paymentPatternPo.setName(name);
        paymentPatternPo.setState(state);
        paymentPatternPo.setBeginTime(beginTime);
        paymentPatternPo.setEndTime(endTime);
        paymentPatternPo.setClassName(className);
        return paymentPatternPo;
    }

    public PaymentPatternVo(PaymentPatternPo paymentPatternPo){
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        id = paymentPatternPo.getId();
        name = paymentPatternPo.getName();
        state = paymentPatternPo.getState();
        beginTime = paymentPatternPo.getBeginTime();
        endTime = paymentPatternPo.getEndTime();
        className = paymentPatternPo.getClassName();
        creator = new SimpleAdminUser(paymentPatternPo.getCreatorId(), paymentPatternPo.getCreatorName());
        gmtCreate = paymentPatternPo.getGmtCreate();
        gmtModified = paymentPatternPo.getGmtModified();
        modifier = new SimpleAdminUser(paymentPatternPo.getModifierId(), paymentPatternPo.getModifierName());
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() { return this; }
}
